"""
with open(file_path,mode,encoding) as f:
    f.write(str)
    f.read()
    # 不需要使用close方法
"""
import time
file_path = "D:\移通学院\双体\课件准备\第一阶段\备课信息\静夜思.txt"
str = "nihao libai"
with open(file_path,mode="a",encoding="utf-8") as f:
    f.write(str)
    f.flush()
time.sleep(1000000000)